﻿using System;

namespace FirstHomework1
{
    class Program
    {
        private const int Number = 11;
        static void Main(string[] args)
        {

            RightAngledTriangle();//输出直角三角形
            IsoscelesTriangle();//输出等腰三角形
            HollowIsoscelesTriangle();//输出空心等腰三角形
            HollowDiamond();//输出空心菱形
            Console.ReadKey();
        }
        /// <summary>
        /// 输出直角三角形
        /// </summary>
        static void RightAngledTriangle()
        {
            Console.WriteLine("直角三角形:");
            for (int i = 0; i < Number; i++)
            {
                Console.WriteLine(new String('*', i + 1));
            }
        }
        /// <summary>
        /// 输出等腰三角形
        /// </summary>
        static void IsoscelesTriangle()
        {
            Console.WriteLine("等腰三角形:");
            for (int i = 0; i <= Number / 2; i++)
            {
                Console.Write(new String(' ', Number / 2 - i));
                Console.WriteLine(new String('*', 2 * i + 1));
            }
        }
        /// <summary>
        /// 输出空心等腰三角形
        /// </summary>
        static void HollowIsoscelesTriangle()
        {
            Console.WriteLine("空心等腰三角形:");
            for (int i = 0; i <= Number / 2; i++)
            {
                Console.Write(new String(' ', Number / 2 - i));
                Console.Write('*');   //输出每一行第一个‘*’
                if (i == 0)
                {
                    Console.WriteLine();   //第一行只有顶点一个‘*’    
                }
                else if (i == Number/2 )
                {
                    Console.WriteLine(new String('*', 2 * i ));   //最后一行为底边，
                }
                else
                {
                    Console.Write(new String(' ', i * 2 - 1));
                    Console.WriteLine('*');
                }
            }
        }
        /// <summary>
        ///输出空心菱形 
        /// </summary>
        static void HollowDiamond()
        {
            Console.WriteLine("空心菱形:");
            for (int i = 0; i <= Number / 2; i++)   //菱形上半部分
            {
                Console.Write(new String(' ', Number / 2 - i));
                Console.Write('*');   //输出每一行第一个‘*’
                if (i == 0)
                {
                    Console.WriteLine();  //第一行只有一个‘*’
                }
                else
                {
                    Console.Write(new String(' ', 2 * i - 1));
                    Console.WriteLine('*');
                }
            }
            for (int i = Number/2 - 1; i >= 0; i--)
            {
                Console.Write(new String(' ', Number / 2 - i));
                Console.Write('*');
                if (i == 0)
                {
                    Console.WriteLine();
                }
                else
                {
                    Console.Write(new String(' ', 2 * i - 1));
                    Console.WriteLine('*');
                }
            }
        }
    }
}
